package com.zl.tby.screen.service.impl;

import com.zl.tby.model.TbyFireRating;
import com.zl.tby.model.TbyFireTime;
import com.zl.tby.screen.service.ITbyForestScreenService;
import com.zl.tby.screen.vo.forest.TbyForestScreenBean;
import com.zl.tby.service.ITbyFireRatingService;
import com.zl.tby.service.ITbyFireTimeService;
import org.noear.solon.annotation.Component;
import org.noear.solon.annotation.Inject;
import org.noear.wood.utils.StringUtils;

import java.math.BigDecimal;

/**
 * 火情监测大屏接口实现类
 * @author changpeng
 * @version 1.0
 * @since 2024/8/19 10:19
 */
@Component
public class TbyForestScreenServiceImpl implements ITbyForestScreenService {

    @Inject
    private ITbyFireRatingService tbyFireRatingService;
    @Inject
    private ITbyFireTimeService tbyFireTimeService;

    @Override
    public TbyForestScreenBean getConfig() {
        TbyFireRating ratingDetail = this.tbyFireRatingService.get();
        TbyFireTime timeDetail = this.tbyFireTimeService.get();
        TbyForestScreenBean entity = new TbyForestScreenBean();
        entity.setFireRating(StringUtils.isEmpty(ratingDetail.getFireDangerRating()) ? "0" : ratingDetail.getFireDangerRating());
        entity.fillYearAndDay(timeDetail.getOccurrenceTime());

        entity.setWeather(ratingDetail.getWeather());
        entity.setTemperature(ratingDetail.getTemperature());
        entity.setWeatherType(ratingDetail.getWeatherType());
        entity.setAqi(ratingDetail.getAqi());
        entity.setWindDirection(ratingDetail.getWindDirection());
        entity.setHumidity(ratingDetail.getHumidity());
        /**紫外线等级(1:弱 2：较弱 3：中等 4：较强 5强)*/
        entity.setUltravioletRays(ratingDetail.getUltravioletRays());
        return entity;
    }
}
